#pragma once

#include "rng.h"

namespace kp {

	struct CameraSample {
		Point2f pFilm;
		Point2f pLens;
		Float time = 0;
	};

	struct Sample : public CameraSample {

	};

	class Sampler {
	public:
		Sampler(int spp)
			:spp(spp)
		{}

		virtual void start_pixel(const Vec2i& pixel, const Vec2i size) = 0;
		virtual Float get1D() = 0;
		virtual Point2f get2D() = 0;
		CameraSample getCameraSample(const Point2i& pRaster);

		const int spp;
	};

	class PixelSampler : public Sampler {
	public:
		PixelSampler(int spp, unsigned int seed = 0)
			:Sampler(spp), rng(seed)
		{}

		virtual void start_pixel(const Vec2i& pixel, const Vec2i size) override {
			rng = RNG(pixel.x + pixel.y * (size_t)size.x);
		}

		virtual Float get1D() override {
			return rng.uniformFloat();
		}

		virtual Point2f get2D() override {
			return { rng.uniformFloat(),rng.uniformFloat() };
		}

	private:
		RNG rng;

	};

}
